package commonlib
{
	import flash.utils.ByteArray;

	public class L
	{
		public static const zh_CN:String = "zh_CN";
		public static const zh_HK:String = "zh_HK";
		public static const zh_EN:String = "zh_EN";
		
		public static const connect_error:String = "connect_error";
		public static const game_daxiao:String = "game_daxiao";
		public static const game_fqzs:String = "game_fqzs";
		public static const game_dantiao:String = "game_dantiao";
		
		[Embed(source = "/assets/locale/language.xml", mimeType = "application/octet-stream")]
		private static const m_languageClass:Class;	
		
		private static var m_languageXml:XML;
		
		public function L()
		{
		}
		
		private static function initXml():void
		{
			if(m_languageXml == null)
			{
				var byteArray:ByteArray = new m_languageClass() as ByteArray;
				var str:String = byteArray.readUTFBytes(byteArray.length);
				if(str.charCodeAt(0) == 65279) str = str.slice(1);
				m_languageXml = new XML(str);
			}
		}
		
		public static function getL(name:String, type:String):String
		{
			initXml();
			if(!m_languageXml) return "";
			var l:XML = m_languageXml.language.(@type = type)[0];
			var content:String = l && l.item.(@name = name)[0] ? l.item.(@name = name)[0] : "";
			return content;
		}
	}
}